This invention relates to an art for managing file system on a non-volatile memory and, more particularly, to an art for formatting a non-volatile memory and a memory card on which a non-volatile memory is mounted.
A prior file management method of a non-volatile memory is explained, referring to a paper titled "Recent trend: Growing interest in flash memory card" written by Kiyota in the magazine "Nikkei Byte", pp.174-182, June, 1994.
FIG. 3 is a figure for explaining a prior file management method of a non-volatile memory.
In the prior method for controlling a file system of a non-volatile memory, a non-volatile memory 4 is divided into two partitions 4a and 4b. Boot records 40a and 40b are allocated to head addresses of the partitions 4a and 4b, respectively.
The boot records 40a and 40b store information including the number of blocks within the partitions 4a and 4b and a head pointer of the directory structure, i.e., each address of root directories 41a and 41b at initializing the medium.
The root directory 41a stores the address of a directory entry 42a. The partition 4a has sub-directory or file information stored in the root directory 41a dispersed therein. An entry chain is connected with the pointer.
The directory entry 42a comprises a primary area where the next entry address is written, a secondary area originally empty where the entry address after updating the directory is stored and an information area where other information including directory names is stored. The primary area stores address information of the before-updated file entry 43a. The secondary area is empty.
The before-updated file entry 43a comprises a primary area where the next entry address is written, a secondary area originally empty where the entry address after updating the file is stored and an information area where other information including file names or the address of actual file data area is stored. The primary area stores the address information of the next entry. The secondary area stores the address of updated file entry 46a.
The information area stores information including file names or the address of the before-updated file information 44a. In case of tracing the pointer of the before-updated file entry 43a in the primary area, the entry is released and non-usable.
The before-updated file information 44a stores information including the date when the file has been produced, attributes and actual file data area, i.e., the address of the before-updated file 45a.
The updated file entry 46a comprises a primary area, a secondary area and an information area. The primary area stores address information of the next entry. The secondary area is empty. The information area stores file names, address of the updated file information 47a and the like.
The updated file information 47a stores information including the date when the file has been produced, attribute and actual file data area, i.e., the address of the updated file 48a.
Block allocation structure areas 49a and 42b store information including block erasing frequency, non-usable and usable data areas.
In the above-structured memory card 4, when updating the file within the directory entry 42a, information on usable data area stored in the block allocation structure area 49a is referred to. It is further confirmed whether there is sufficient area for storing the updating file or information of the file entry that will be updated accompanied therewith.
If the information on the file or the file entry cannot be written because of insufficient size, garbage collection is executed so as to make usable writing area.
When sufficient size of the area is prepared for storing the information of the file or the file entry, the boot record 40a allocated to the head address of the partition 4a is accessed and the address of the root directory 41a is obtained.
According to the address obtained from the boot record 40a, the root directory 41a is accessed. The address of the directory entry 42a is obtained. According to the obtained address, the directory entry 42a is accessed.
If the directory name registered in the directory entry 42a corresponds with that of the updating file, the address of the before-updated file entry 43a is obtained.
The before-updated file entry 43a is accessed according to the obtained address. If the file name registered in the before-updated file entry 43a corresponds with that of the updating file and the secondary area is empty, the address of unoccupied data area within the partition 4a is written in the secondary area.
At the address of the unoccupied data area, updated file entry 46a is produced. The content of the primary area of the before-updated file entry 43a is written into the primary area of the updated file entry 46a. The information area of the updated file entry 46a stores the file names and the address of the next unused data area.
The updated file information 47a is written at the address of the next unused data area that has been written in the information area of the updated file entry 46a. The address of the next unused data area is assigned. After the updated file 48a is actually written at the assigned address, information of the data area which has been used for the block allocation structure area 49a is added.
While in case of reading the file within the directory entry 42a, the boot record 40a allocated to the head address of the partition 4a is accessed and the address of the root directory 41a is obtained.
The root directory 41a is accessed according to the obtained address. The address of the directory entry 42a is obtained and the directory entry 42a is accessed. If the directory name registered in the directory entry 42a corresponds with that of the file which will be read out, the address of the before-updated file entry 43a is obtained.
When accessing the before-updated file entry 43a according to the obtained address, the address of the updated file entry 46a stored in the secondary area is also obtained. This because the address information is stored both in the primary and the secondary areas.
According to the above-obtained address, the updated file entry 46a is accessed. If the file name registered in the updated file entry 46a corresponds with the one which will be read out and the secondary area is empty, the address of the updated file information 47a stored in the information area is obtained.
According to the obtained address, the updated file information 47a is accessed. Then the address of the updated file 48a is obtained and the updated file 48a as the actual data area is read out.
With the above described prior file management method, the directory or file can be updated by adding the updated entry address in the secondary area of the directory entry or file entry. As a result, this method eliminates the need of block erasing process at every data rewriting. However frequent updating of the file or directory unnecessarily elongates the entry chain, thus requiring a long time for tracing the pointer.
Accompanied with increasing released and non-usable data area, usable area within the partition is decreased. Accordingly the file management method is designed to execute garbage collection at a predetermined timing for erasing the released data area and optimizing the entry chain.
This method controls to prevent a specific block from being erased excessively by using the information of the erasing frequency stored in the block allocation structure area 49a.
The conventional file management method as described above is constructed to divide the memory card into a plurality of partitions. When writing the file in a specific partition, only unoccupied area of the same partition is usable as an available area. The unoccupied area of other partition cannot be effectively used.
As a result, file writing needs frequent garbage collection in the same partition, resulting in a long process time.
Unevenness in the erasing frequency among partitions causes varied erasing frequency among blocks, thus shortening the service life of the memory card as a whole. This is caused by the structure of the managing method in which each partition of the memory card is designed to have independent file management.
Alternatively file managing through classifying file groups by directories instead of dividing the memory card into partitions may cause the entry chain of the directory dr file partially illegible, leading to make the most of those files unaccessible. With this method, since the memory card is not divided into partitions, all the directory or file entries have to be connected from one boot record by means of one pointer chain. This is resulted from no redundancy in the FAT (File Allocation Table ) area.